import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
// import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [

  //  {
  //   title: '单据类型id',
  //   align:"center",
  //   dataIndex: 'billTypeId'
  //  },
   {
    title: '单据类型',
    align:"center",
    sorter: true,
    dataIndex: 'billTypeName',
    width: 100
   },
   {
    title: '单据编号',
    align:"center",
    sorter: true,
    dataIndex: 'billCode'
   },
  //  {
  //   title: '币种id',
  //   align:"center",
  //   dataIndex: 'currencyId'
  //  },
  //  {
  //   title: '币种',
  //   align:"center",
  //   dataIndex: 'currencyName',
  //   width: 100
  //  },
   {
    title: '来源类型',
    align:"center",
    dataIndex: 'sourceCategory',
    width: 100,
    customRender: ({ text }) => render.renderDict(text, 'srcBill_type'),
   },
   {
    title: '来源单号',
    align:"center",
    dataIndex: 'srcBillCode'
   },
  //  {
  //   title: '请购单编码',
  //   align:"center",
  //   dataIndex: 'buyingRequisitionCode'
  //  },
  //  {
  //   title: '请购人员id',
  //   align:"center",
  //   dataIndex: 'requisitionPersonnelId'
  //  },
   {
    title: '请购人员',
    align:"center",
    dataIndex: 'requisitionPersonnelName',
    width: 100
   },
  //  {
  //   title: '组织',
  //   align:"center",
  //   dataIndex: 'organizationName'
  //  },
   {
    title: '日期',
    align:"center",
    sorter: true,
    dataIndex: 'buyingRequisitionDate'
   },
  //  {
  //   title: '请购部门id',
  //   align:"center",
  //   dataIndex: 'requisitionDepartmentId'
  //  },
   {
    title: '请购部门',
    align:"center",
    dataIndex: 'requisitionDepartmentName',

   },
   {
    title: '单据状态',
    align:"center",
    dataIndex: 'billStatus',
    ifShow:false,
    customRender: ({ text }) => render.renderDict(text, 'sale_order_bill_status')
   },
  //  {
  //   title: '是否已推送',
  //   align:"center",
  //   ifShow:false,
  //   dataIndex: 'isPush',
  //   customRender: ({ text }) => render.renderDict(text, 'yn')
  //  },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
  //  {
  //   title: '第三方编码',
  //   align:"center",
  //   dataIndex: 'thirdPartyCode',
  //   ifShow: false
  //  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "单据类型",
      field: "billTypeName",
      component: 'JDictSelectTag',
      componentProps:{
      },
      colProps: {span: 6},
 	},
	{
      label: "单据编号",
      field: "billCode",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "来源类型",
      field: "sourceCategory",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"srcBill_type",
          stringToNumber: true,
      },
      colProps: {span: 6},
 	},
	{
      label: "来源单号",
      field: "srcBillCode",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "日期",
      field: "buyingRequisitionDate",
      component: 'DatePicker',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '单据类型id',
    field: 'billTypeId',
    component: 'Input',
    show:false
  },
  {
    label: '单据类型',
    field: 'billTypeName',
    component: 'Input',
    slot:'billTypeSlot',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入单据类型!' },
      ];
    },
  },
  {
    label: '单据编号',
    field: 'billCode',
    component: 'Input',
    dynamicDisabled:true,
    componentProps: {
        placeholder: '自动生成',
      },
  },
  {
    label: '币种id',
    field: 'currencyId',
    component: 'Input',
    show:false
  },
  {
    label: '币种',
    field: 'currencyName',
    component: 'Input',
    slot: 'currencySlot',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入币种!' },
      ];
    },
  },
  {
    label: '来源单号',
    field: 'srcBillCode',
    component: 'Input',
  },
  {
    label: '来源类别',
    field: 'srcBillType',
    defaultValue:1,
    component: 'JDictSelectTag',
      componentProps:{
          dictCode:"srcBill_type",
          stringToNumber: true,
      },
  },
  {
    label: '请购单编码',
    field: 'buyingRequisitionCode',
    component: 'Input',
    show:false
  },
  {
    label: '请购人员id',
    field: 'requisitionPersonnelId',
    component: 'Input',
    show:false
  },
  {
    label: '请购人员',
    field: 'requisitionPersonnelId',
    component: 'JSelectUserByDept',
    componentProps: {
      showButton:false,
      isRadioSelection:true,
      rowKey:"id",
      labelKey: 'realname',
      flag: true
    }
  },
  {
    label: '组织id',
    field: 'organizationId',
    component: 'Input',
    show: false,
  },
  {
    label: '业务组织',
    field: 'organizationName',
    component: 'Input',
    componentProps:{
      disabled:true,
      placeholder:"自动获取登录组织"
    }
  },
  {
    label: '日期',
    field: 'buyingRequisitionDate',
    component: 'DatePicker',
  },
  {
    label: '请购部门id',
    field: 'requisitionDepartmentName',
    component: 'Input',
    show:false
  },
  {
    label: '请购部门',
    field: 'requisitionDepartmentId',
    component: 'JSelectDept',
    componentProps:({})=>{
      return{
        multiple: false,
        labelKey: 'departName',
        showButton:false,
        checkable:false
      }
    },
  },
  {
    label: '供应商id',
    field: 'supplierId',
    component: 'Input',
    show:false
  },
  {
    label: '供应商编号',
    field: 'supplierCode',
    component: 'Input',
    show:false
  },
  {
    label: '默认供应商',
    field: 'supplierName',
    component: 'Input',
    slot: 'supplierSlot'
  },
  {
    label: '单据状态',
    field: 'billStatus',
    component: 'JDictSelectTag',
    show:false,
    defaultValue:0,
    componentProps:{
        dictCode:"sale_order_bill_status",
        stringToNumber: true,
     },
  },
  {
    label: '是否已推送',
    field: 'isPush',
    component: 'JDictSelectTag',
    dynamicDisabled:true,
    show:false,
    defaultValue:0,
    componentProps:{
        dictCode:"yn",
        stringToNumber: true,
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
    ifShow: false
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置  请购行信息
export const busBuyingRequisitionItemColumns: JVxeColumn[] = [
    {
      title: '行号',
      key: 'rowNum',
      type: JVxeTypes.normal,
      width:"100px",
      validateRules:[{required:true,message:'${title}不能为空'}]
    },
    {
      title: '租户id',
      key: 'tenantId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '请购单Id',
      key: 'buyingRequisitionId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '供应商ID',
      key: 'supplierId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
    },
    {
      title: '供应商',
      key: 'supplierName',
      type: JVxeTypes.slot,
      slotName: 'supplierSlot',
      width:"200px",
      placeholder: '请输入${title}',
    },
    {
      title: '料品ID',
      key: 'materialId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '料号',
      key: 'materialCode',
      type: JVxeTypes.slot,
      slotName: 'action',
      width:"150px",
      placeholder: '请输入${title}',
      defaultValue:'',
      validateRules: [
        {
          required: true,
          message: '请选择料号'
        }
      ]
    },
    {
      title: '品名',
      key: 'materialName',
      type: JVxeTypes.normal,
      width:"150px",
      placeholder: '请输入${title}',
    },
    {
      title: '规格',
      key: 'specifications',
      type: JVxeTypes.normal,
      width:"120px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单位id',
      key: 'unitId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  {
    title: '单位',
    key: 'unitName',
    width: "120px",
    type: JVxeTypes.input,
    disabled:true
  },
    {
      title: '原始订单号',
      key: 'originalBillCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '原始订单行号',
      key: 'originalRowNum',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '组织id',
      key: 'organizationId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '业务组织',
      key: 'organizationName',
      type: JVxeTypes.slot,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      slotName: 'organizationSlot',
    },
    {
      title: '请购数量',
      key: 'requisitionQuantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
      validateRules: [
        {
          required: true,
          message: '请选择请购数量'
        }
      ]
    },
    {
      title: '采购数量',
      key: 'purchaseQuantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '需求交期',
      key: 'deliveryDate',
      type: JVxeTypes.datetime,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '建议价格',
      key: 'suggestedPrice',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据ID',
      key: 'srcBillId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单号',
      key: 'srcBillCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '番号',
      key: 'designation',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '项目号id',
      key: 'projectId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '项目号编码',
      key: 'projectCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '需求分类',
      key: 'requirementsType',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
]

// 子表表格配置  采购信息
export const busBuyingRequisitionPurchaseColumns: JVxeColumn[] = [
    {
      title: '请购单ID',
      key: 'buyingRequisitionId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '请购单号',
      key: 'buyingRequisitionCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '请购行号',
      key: 'buyingRequisitionRowNumber',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '采购单号',
      key: 'purchaseCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '采购行号',
      key: 'purchaseRowNumber',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '供应商ID',
      key: 'supplierId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '供应商',
      key: 'supplierName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '料品ID',
      key: 'materialId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '料号',
      key: 'materialCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '品名',
      key: 'materialName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '规格',
      key: 'specifications',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单位ID',
      key: 'unitId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单位',
      key: 'unitName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '请购数量',
      key: 'requisitionQuantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '采购数量',
      key: 'purchaseQuantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '要货数量',
      key: 'requireGoodQuantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '已交货数',
      key: 'deliveredQuantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '需求交期',
      key: 'deliveryDate',
      type: JVxeTypes.date,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单据状态',
      key: 'billStatus',
      type: JVxeTypes.hidden,
    },
    {
      title: '备注',
      key: 'remark',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据ID',
      key: 'srcBillId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单号',
      key: 'srcBillCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据类型ID',
      key: 'srcBillTypeId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据类型',
      key: 'srcBillTypeName',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据明细ID',
      key: 'srcBillItemId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源行号',
      key: 'srcRowNumber',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '源头单据ID',
      key: 'firstBillId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '源头单据编号',
      key: 'firstBillCode',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '源头单据类型ID',
      key: 'firstBillTypeId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '源头单据类型',
      key: 'firstBillTypeName',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '删除状态',
      key: 'delFlag',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '创建方式',
      key: 'createMethod',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '第三方编码',
      key: 'thirdPartyCode',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '组织ID',
      key: 'organizationId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '租户ID',
      key: 'tenantId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}